package com.jbm.jbmsupplier.zp.FactouryActivity.FacturyChatBaseAdapter;

import android.content.Context;

import com.jbm.jbmsupplier.R;
import com.jbm.jbmsupplier.zp.adapters.ChatMsgViewAdapter;
import com.jbm.jbmsupplier.zp.entity.ChatMsgEntity;
import com.jbm.jbmsupplier.zp.sqldata.MySqliteUtlis;
import com.jbm.jbmsupplier.zp.utils.ClassUser;

import org.xutils.image.ImageOptions;
import org.xutils.x;

import java.util.List;

import static com.jbm.jbmsupplier.zp.utils.TableName.BUDDY;

/**
 * Created by 家帮忙 on 2017/7/17.
 */

public class ReceAdapterSendText implements ChatBaseInterfaces{
    @Override
    public void setDataAdapter(ChatMsgViewAdapter.ViewHolder viewHolder, int position, int type, List<ChatMsgEntity> coll, String stShowSendTime, Context context,int to_id) {
        viewHolder.tvUserName.setText(String.valueOf(coll.get(position).getTo_id()));
        viewHolder.tvSendTime.setText(stShowSendTime);
        viewHolder.tvContent.setText(coll.get(position).getText());
        if (coll.get(position).getTags()==1){
            viewHolder.iv_userheads.setImageDrawable(context.getResources().getDrawable(R.mipmap.pic));
        }else
        if (MySqliteUtlis.GetInstan(context).showFriendsToID(BUDDY ,to_id,new ClassUser(context).getLogin()).getHead_portrait().equals("")){
            viewHolder.iv_userheads.setImageDrawable(context.getResources().getDrawable(R.mipmap.pic));
        }else {
            ImageOptions i=new ImageOptions.Builder().setCircular(true).build();
            x.image().bind(viewHolder.iv_userheads,MySqliteUtlis.GetInstan(context).showFriendsToID(BUDDY , to_id,new ClassUser(context).getLogin()).getHead_portrait(),i);
        }
    }
}
